﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace Wpf.CommonTools.Converter
{
    public class EnumHasFlagMultiConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                return false;
            }
            else
                if (values != null && values.Length == 2)
                {

                    int flag = System.Convert.ToInt32(values[0] ?? 0);
                    int p = System.Convert.ToInt32(values[1] ?? 0);
                    return (p & flag) == p;
                }
                else
                {
                    return false;
                }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
